package com.esp.soccertutor.ui;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

import com.esp.soccertutor.R;
import com.esp.soccertutor.android.fbreader.FBReader;
import com.esp.soccertutor.fbreader.fbreader.ChangeFontFamilyAction;
import com.esp.soccertutor.fbreader.fbreader.ChangeFontSizeAction;
import com.esp.soccertutor.fbreader.fbreader.ChangeHypenAction;
import com.esp.soccertutor.fbreader.fbreader.ChangeLineSpace;
import com.esp.soccertutor.fbreader.fbreader.FBReaderApp;
import com.esp.soccertutor.uc.GS_Home_Bottom_Menu;
import com.esp.soccertutor.util.Bean;
import com.esp.soccertutor.util.ColorPickerDialog;
import com.esp.soccertutor.util.Const;
import com.esp.soccertutor.util.Log;
import com.esp.soccertutor.util.Pref;
import com.esp.soccertutor.zlibrary.core.application.ZLApplication;
import com.esp.soccertutor.zlibrary.core.options.ZLBooleanOption;
import com.esp.soccertutor.zlibrary.core.options.ZLIntegerRangeOption;
import com.esp.soccertutor.zlibrary.core.util.ZLColor;

public class AppHome extends Activity implements ColorPickerDialog.OnColorChangedListener{
    /** Called when the activity is first created. */
	//Appearance Home Activity
	
	private GS_Home_Bottom_Menu mMenu;
	private Button _btnRead;
	private CheckBox _cboxautoload;
	private TextView _tv_fsize,_tv_selectedtheme,_tv_FontName;
	private TextView _tv_textcolorbox,_tv_linkcolorbox,_tv_bgcolorbox;
	private SeekBar sbfontsize;
	private int intfontsize=5;
	private static String flag;
	private ZLColor colortext,colorhyper;
	private ZLIntegerRangeOption infontsize;
	
	private TextView txtSetting;
	public TextView _tv_alignmentvalue,_tv_LinespaceValue,_tv_marginsValue,_tv_PgSpacingValue,_tv_PgIndentValue=null,_tv_PgIndent;
	private String[]strAlignment={"Undefine","Left","Right","center","Justify"};
	private CheckBox _cbox_hypen; 
	private SeekBar _seekbar_LineSpacing,_seekbar_margins,_seekbar_PgSpacing;
	private static int intlinespce,intmargin,intpgspacing;
	private ZLIntegerRangeOption intLineSpece,intTopMargin,intBottomMargin,SpaceBeforeOption,LeftIndentOption;
	private ZLIntegerRangeOption intLeftMargin,intRightMargin;
	private static String[] entries;
    
	private RelativeLayout container_font,Container_alignment;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_NO_TITLE);// hide window title
        
        setContentView(R.layout.apperance_home);//Set Layout
        
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
             
        txtSetting = (TextView)findViewById(R.id.txtSetting);
        txtSetting.setTypeface(Const.tf);
        
        //this.mMenu = new GS_Home_Bottom_Menu(this, getLayoutInflater());
        _btnRead = (Button)findViewById(R.id.btnRead);
		_tv_fsize=(TextView)findViewById(R.id._tv_fsize);
		
		/*_tv_selectedtheme=(TextView)findViewById(R.id._tv_selectedtheme);
		_tv_selectedtheme.setText(Pref.getValue("DAY_NIGHT_MODE", "DAY"));
		_tv_textcolorbox=(TextView)findViewById(R.id._tv_textcolorbox);
		_tv_linkcolorbox=(TextView)findViewById(R.id._tv_linkcolorbox);
		_tv_bgcolorbox=(TextView)findViewById(R.id._tv_bgcolorbox);*/
		
		_tv_FontName=(TextView)findViewById(R.id._tv_FontName);
    
		_btnRead.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), FBReader.class));
			}
		});
		
        infontsize=new ZLIntegerRangeOption("Style","Base:fontSize",5,72,0);
    
        sbfontsize=(SeekBar)findViewById(R.id._seekbar_fontsize);
        sbfontsize.setMax(72);
        sbfontsize.setKeyProgressIncrement(1);
        sbfontsize.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			
			public void onStopTrackingTouch(SeekBar seekBar) {
				
				//System.out.println("SeekBarValue : :"+intfontsize);
				_tv_fsize.setText(String.valueOf(intfontsize));
				FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
				new ChangeFontSizeAction(fbReader,intfontsize).run();
				
			}
			

			public void onStartTrackingTouch(SeekBar seekBar) {
				
			}
			
			
			public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
				
				if(progress<=5){
					intfontsize=5;
				}else{
					intfontsize=progress;
					infontsize.setValue(intfontsize);
					_tv_fsize.setText(String.valueOf(intfontsize));
					Log.print("AppHome : :onProgressChanged ::",""+intfontsize);
					
				}
			}
		});
       
        /*_tv_bgcolorbox.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				final AlertDialog bgwallpaper;
				
				if(_tv_selectedtheme.getText().equals("DAY")){
					bgwallpaper= new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(Const.DAY_BG_NAME,Bean.getWallIndex(Bean.getThemeBg("DAY"),"DAY"),new DialogInterface.OnClickListener() {
						
						@Override
						public void onClick(DialogInterface dialog, int index) {
							
							Bean.setThemeBg("DAY",index);
							Log.print("AppHome ::SET DAY BGWALLPAPER",""+Const.DAY_BG_NAME[index]);
							_tv_bgcolorbox.setBackgroundResource(Const.DAY_BG[index]);
							dialog.dismiss();
						}
						
					 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							Log.print("AppHome ::SET DAY BGWALLPAPER","CANCEL");
							dialog.dismiss();
						}
					}).create();
					bgwallpaper.setTitle("Background Wallpaper");
					bgwallpaper.show();
					
				}else{
					bgwallpaper= new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(Const.NIGHT_BG_NAME,Bean.getWallIndex(Bean.getThemeBg("NIGHT"),"NIGHT"),new DialogInterface.OnClickListener() {
						
						@Override
						public void onClick(DialogInterface dialog, int index) {
							
							Bean.setThemeBg("NIGHT",index);
							Log.print("AppHome ::SET NIGHT BGWALLPAPER",""+Const.NIGHT_BG_NAME[index]);
							_tv_bgcolorbox.setBackgroundResource(Const.NIGHT_BG[index]);
							dialog.dismiss();
							
						}
						
					 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {
							Log.print("AppHome ::SET NIGHT BGWALLPAPER","CANCEL");
							dialog.dismiss();
						}
					}).create();
					bgwallpaper.setTitle("Background Wallpaper");
					bgwallpaper.show();
					
				}
				
				
				
			}
		});*/
        
       
       /* _tv_textcolorbox.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				if(Pref.getValue("DAY_NIGHT_MODE","DAY").equals("NIGHT")){
					
					ZLColorOption regText=new ZLColorOption("Colors","defaultDark:Text",new ZLColor(192,192,192));
					new CustomDialog(getApplicationContext(),getLayoutInflater(),regText,"Regular Text",_tv_textcolorbox, "NIGHT_TEXT_COLOR_VALUE").show(v);
					
				}else{
					
					ZLColorOption regText=new ZLColorOption("Colors","defaultLight:Text",new ZLColor(0,0,0));
					new CustomDialog(getApplicationContext(),getLayoutInflater(),regText,"Regular Text",_tv_textcolorbox, "DAY_TEXT_COLOR_VALUE").show(v);
					
				}
				
			}
		});*/
       
       /* _tv_linkcolorbox.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				if(Pref.getValue("DAY_NIGHT_MODE","DAY").equals("NIGHT")){
					
					ZLColorOption hypetext=new ZLColorOption("Colors","defaultDark:Hyperlink",new ZLColor(60,142,224));
					new CustomDialog(getApplicationContext(),getLayoutInflater(),hypetext,"HyperText",_tv_linkcolorbox, "NIGHT_LINK_COLOR_VALUE").show(v);
				}else{
					
					ZLColorOption hypetext=new ZLColorOption("Colors","defaultLight:Hyperlink",new ZLColor(60,139,255));
					new CustomDialog(getApplicationContext(),getLayoutInflater(),hypetext,"HyperText",_tv_linkcolorbox, "DAY_LINK_COLOR_VALUE").show(v);
				
				}
				
			}
		});*/
        
        container_font =(RelativeLayout)findViewById(R.id.container_font);
        container_font.setOnClickListener(new OnClickListener() {
			
			
			public void onClick(View v) {
					final AlertDialog fontSize = new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(Const.strFontName,Bean.getFontIndex(Bean.getFontName()),new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int index) {
						Bean.setFontName(index);
						_tv_FontName.setText(Bean.getFontName());
						FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
						new ChangeFontFamilyAction(fbReader,Bean.getFontName()).run();
						dialog.dismiss();
						
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int which) {
						
						dialog.dismiss();
						
					}
				}).create();
				
			    fontSize.setTitle("Font Name");
		        fontSize.show();
			}
		});
        
        
        _tv_FontName.setText(Bean.getFontName());
        _tv_FontName.setOnClickListener(new OnClickListener() {
			
			
			public void onClick(View v) {
				
				final AlertDialog fontSize = new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(Const.strFontName,Bean.getFontIndex(Bean.getFontName()),new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int index) {
						Bean.setFontName(index);
						_tv_FontName.setText(Bean.getFontName());
						FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
						new ChangeFontFamilyAction(fbReader,Bean.getFontName()).run();
						dialog.dismiss();
						
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int which) {
						
						dialog.dismiss();
						
					}
				}).create();
				
			    fontSize.setTitle("Font Name");
		        fontSize.show();
				
			}
		});
        
        //CHECK DEFAULT VALUE
       // initcheck();
        
        _cboxautoload=(CheckBox)findViewById(R.id._cboxAutoLoadBk);
        checkCBoxValue();
        _cboxautoload.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if(isChecked){
						Log.print("ACT_GSHOME::OnCreate:CheckBox ",""+_cboxautoload.isChecked());
						Pref.setValue("GEN_SET_AUTO_LOAD_LAST_BOOK", "YES");
						
				}else{
						Log.print("ACT_GSHOME::OnCreate:CheckBox ",""+_cboxautoload.isChecked());
						Pref.setValue("GEN_SET_AUTO_LOAD_LAST_BOOK", "NO");
				}
			}
		});
        
        
        _cbox_hypen=(CheckBox)findViewById(R.id._cbox_hypen);
        _seekbar_LineSpacing=(SeekBar)findViewById(R.id._seekbar_LineSpacing);
        _seekbar_margins=(SeekBar)findViewById(R.id._seekbar_margins);
        _seekbar_PgSpacing=(SeekBar)findViewById(R.id._seekbar_PgSpacing);
       
        
        
        _tv_marginsValue=(TextView)findViewById(R.id._tv_marginsValue);
        _tv_LinespaceValue=(TextView)findViewById(R.id._tv_LinespaceValue);
        _tv_PgSpacingValue=(TextView)findViewById(R.id._tv_PgSpacingValue);
        
        intLineSpece=new ZLIntegerRangeOption("Style","Base:lineSpacing",5,20,12);
        intTopMargin=new ZLIntegerRangeOption("Options", "TopMargin",0,30,15);
        intBottomMargin=new ZLIntegerRangeOption("Options","BottomMargin",0,30,15);
        intLeftMargin = new ZLIntegerRangeOption("Options","LeftMargin",0,30,15);
        intRightMargin = new ZLIntegerRangeOption("Options","RightMargin",0,30,15);
        
        SpaceBeforeOption=new ZLIntegerRangeOption("Style","Regular Paragraph:spaceBefore", -10,100, 0);
        LeftIndentOption = new ZLIntegerRangeOption("Style","Regular Paragraph:leftIndent", -300, 300, 0);
        
        
        Container_alignment = (RelativeLayout)findViewById(R.id.Container_alignment);
        Container_alignment.setOnClickListener(new OnClickListener() {
			
			
			public void onClick(View v) {

				
				final AlertDialog fontSize = new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(strAlignment,Bean.getAlignmentIndex(Bean.getAlignment()),new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int index) {
						Bean.setAlignment(index);
						_tv_alignmentvalue.setText(strAlignment[index]);
						dialog.dismiss();
						
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int which) {
						
						dialog.dismiss();
						
					}
				}).create();
				
			    fontSize.setTitle("Alignment Name");
		        fontSize.show();	
			
			}
		});
        
        
        _tv_alignmentvalue=(TextView)findViewById(R.id._tv_alignmentvalue);
        _tv_alignmentvalue.setText(Bean.getAlignment());
        _tv_alignmentvalue.setOnClickListener(new OnClickListener() {
			
			
			public void onClick(View v) {
				
				final AlertDialog fontSize = new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(strAlignment,Bean.getAlignmentIndex(Bean.getAlignment()),new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int index) {
						Bean.setAlignment(index);
						_tv_alignmentvalue.setText(strAlignment[index]);
						dialog.dismiss();
						
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					
					
					public void onClick(DialogInterface dialog, int which) {
						
						dialog.dismiss();
						
					}
				}).create();
				
			    fontSize.setTitle("Alignment Name");
		        fontSize.show();	
			}
		});
        
      
        _cbox_hypen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				
				Log.print("LayHome ::OnCreate:CheckBoxHypen ",""+_cbox_hypen.isChecked());
				new ZLBooleanOption("Options","AutoHyphenation",true).setValue(_cbox_hypen.isChecked());
				FBReaderApp fbReader = (FBReaderApp)ZLApplication.Instance();
				new ChangeHypenAction(fbReader,isChecked).run();
			}
		});
        
        _seekbar_LineSpacing.setMax(20);
        _seekbar_LineSpacing.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			
			public void onStopTrackingTouch(SeekBar seekBar) {
				
				_tv_LinespaceValue.setText(String.valueOf(intlinespce));
				
				
			}
			
			
			public void onStartTrackingTouch(SeekBar seekBar) {
				
			}
			
			
			public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
				
				if(progress<=5){
					intlinespce=5;
					intLineSpece.setValue(intlinespce);
					_tv_LinespaceValue.setText(String.valueOf(intlinespce));
					Log.print("LayHome : :onProgressChanged ::LineSpace ",""+intlinespce);
					FBReaderApp fbReader = (FBReaderApp)ZLApplication.Instance();
					new ChangeLineSpace(fbReader,intlinespce).run();
					
				}else{
					intlinespce=progress;
					_tv_LinespaceValue.setText(String.valueOf(intlinespce));
					intLineSpece.setValue(intlinespce);
					Log.print("LayHome : :onProgressChanged ::LineSpace ",""+intlinespce);
					FBReaderApp fbReader = (FBReaderApp)ZLApplication.Instance();
					new ChangeLineSpace(fbReader,intlinespce).run();
				}
			}
		});
        _seekbar_margins.setMax(30);
        _seekbar_margins.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			
			public void onStopTrackingTouch(SeekBar seekBar) {
				_tv_marginsValue.setText(String.valueOf(intmargin));
			}
			
			
			public void onStartTrackingTouch(SeekBar seekBar) {
			}
			
			
			public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
				
				if(progress>=0){
					intmargin=progress;
					_tv_marginsValue.setText(String.valueOf(intmargin));
					intTopMargin.setValue(intmargin);
					intBottomMargin.setValue(intmargin);
					intLeftMargin.setValue(intmargin);
					intRightMargin.setValue(intmargin);
					Log.print("LayHome : :onProgressChanged ::Margin : :",""+intmargin);
					
				}
			}
		});
        
        _seekbar_PgSpacing.setMax(100);
        _seekbar_PgSpacing.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			
			
			public void onStopTrackingTouch(SeekBar seekBar) {
				
				_tv_PgSpacingValue.setText(String.valueOf(intpgspacing));
				
			}
			
			
			public void onStartTrackingTouch(SeekBar seekBar) {
				
				
			}
			
			
			public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
				
				intpgspacing=progress;
				_tv_PgSpacingValue.setText(String.valueOf(intpgspacing));
				SpaceBeforeOption.setValue(intpgspacing);
				Log.print("LayHome : :onProgressChanged ::PgSpacing Before : :",""+intpgspacing);
				
			}
		});
        
       
        
    	entries = new String[601];
		for (int i = 0; i <entries.length;i++) {
			entries[i] = ((Integer)(i +(-300))).toString();
			//System.out.println(entries[i]);
		}
        
       /* _tv_PgIndentValue.setOnClickListener(new OnClickListener() {
			
        	
			@Override
			public void onClick(View v) {
				final AlertDialog pgIndent= new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(entries,Bean.getIndex(entries,String.valueOf(LeftIndentOption.getValue())),new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int index) {
						//System.out.println(" SELECT "+entries[index]);
						
						LeftIndentOption.setValue(Integer.parseInt(entries[index]));
						_tv_PgIndentValue.setText(entries[index]);
						dialog.dismiss();
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
					}
				}).create();
				pgIndent.setTitle("Paragraph Indent");
				pgIndent.show();
			}
		});
        _tv_PgIndent.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
					final AlertDialog pgIndent= new AlertDialog.Builder(AppHome.this).setSingleChoiceItems(entries,Bean.getIndex(entries,String.valueOf(LeftIndentOption.getValue())),new DialogInterface.OnClickListener() {
					
					@Override
					public void onClick(DialogInterface dialog, int index) {
						//System.out.println(" SELECT "+entries[index]);
						
						LeftIndentOption.setValue(Integer.parseInt(entries[index]));
						_tv_PgIndentValue.setText(entries[index]);
						dialog.dismiss();
					}
					
				 }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
					}
				}).create();
				pgIndent.setTitle("Paragraph Indent");
				pgIndent.show();
			}
		});*/
        
        
        initCheck();
        
        
        
   }
    public void onResume(){   	
    	super.onResume();
    }	
    public boolean onKeyDown(int keyCode, KeyEvent event) { 
    	
	    /*if (keyCode == KeyEvent.KEYCODE_MENU) {
	    	doMenu();
	    	return true; //always eat it!	    	
	    }
	    else if(keyCode == KeyEvent.KEYCODE_BACK)
	    {
	    	FBReader.DO_REPAINT=1;
	    	if (mMenu.isShowing()) {
				mMenu.hide();
				return true;
	    	}
	    }*/
		return super.onKeyDown(keyCode, event); 
	} 
	
	/*private void doMenu() {
		if (mMenu.isShowing()) {
			mMenu.hide();
		} else {
			//Note it doesn't matter what widget you send the menu as long as it gets view.
			mMenu.show(findViewById(R.id._ll_apperance_home));
		}
	}*/
	
	private void checkCBoxValue(){
    	
    	if(Pref.getValue("GEN_SET_AUTO_LOAD_LAST_BOOK","YES").toString().endsWith("YES")){
    		_cboxautoload.setChecked(true);
    	}
    	
    	
    }

	
	public void colorChanged(int color) {/*
		
		
		if(AppHome.flag.endsWith("textcolorbox")){
			
			_tv_textcolorbox.setBackgroundColor(color);
			AppHome.flag="";
			if(Pref.getValue("DAY_NIGHT_MODE","DAY").equals("NIGHT")){
				
				Pref.setValue("NIGHT_TEXT_COLOR_VALUE", String.valueOf(color));
				
				ZLColorOption normaltext=new ZLColorOption("Colors","defaultDark:Text",new ZLColor(192,192,192));
				normaltext.setValue(new ZLColor(color));
				
				Log.print("AppHome () : :normaltext colorChanged()","INSERT TO CONFIG.DB"+ new ZLColor(color).getIntValue());
				
				
			}else{
				
				Pref.setValue("DAY_TEXT_COLOR_VALUE", String.valueOf(color));
				
				ZLColorOption normaltext=new ZLColorOption("Colors","defaultLight:Text",new ZLColor(0,0,0));
				normaltext.setValue(new ZLColor(color));
				Log.print("AppHome () : :colorChanged()","INSERT TO CONFIG.DB"+ new ZLColor(color).getIntValue());
				
			}
			
		}
		if(AppHome.flag.endsWith("linkcolorbox")){
			
		
			_tv_linkcolorbox.setBackgroundColor(color);
			AppHome.flag="";
			if(Pref.getValue("DAY_NIGHT_MODE","DAY").equals("NIGHT")){
				
				Pref.setValue("NIGHT_LINK_COLOR_VALUE", String.valueOf(color));
				
				ZLColorOption hypetext=new ZLColorOption("Colors","defaultDark:Hyperlink",new ZLColor(60,142,224));
				hypetext.setValue(new ZLColor(color));
				Log.print("AppHome () : :hypetext colorChanged()","INSERT TO CONFIG.DB"+ new ZLColor(color).getIntValue());
				
			}else{
				
				Pref.setValue("DAY_LINK_COLOR_VALUE", String.valueOf(color));
				
				ZLColorOption hypetext=new ZLColorOption("Colors","defaultLight:Hyperlink",new ZLColor(60,139,255));
				hypetext.setValue(new ZLColor(color));
				Log.print("AppHome () : :hypetext colorChanged()","INSERT TO CONFIG.DB"+ new ZLColor(color).getIntValue());
			}
		}
		
		
	*/}
	/*public void initcheck(){
		
		if(Pref.getValue("DAY_NIGHT_MODE","DAY").equals("NIGHT")){
			
			//defaultText=new ZLColorOption("Colors","defaultDark:Text",new ZLColor(192,192,192)).getValue().getIntValue();
			colortext=new ZLColorOption("Colors","defaultDark:Text",new ZLColor(255, 255, 255)).getValue();
			Log.print("AppHome : : initcheck()", "NIGHT MODE: :defaultText "+ colortext.getIntValue());
			
			Pref.setValue("NIGHT_TEXT_COLOR_VALUE", String.valueOf(colortext.getIntValue()));
			
			_tv_textcolorbox.setBackgroundColor(Color.rgb(colortext.Red,colortext.Green,colortext.Blue));
			
			colorhyper=new ZLColorOption("Colors","defaultDark:Hyperlink",new ZLColor(60,142,224)).getValue();
			Log.print("AppHome : : initcheck()", "NIGHT MODE: :defaulthyper "+ colorhyper.getIntValue());
			
			Pref.setValue("NIGHT_LINK_COLOR_VALUE", String.valueOf(colorhyper.getIntValue()));
			
			_tv_linkcolorbox.setBackgroundColor(Color.rgb(colorhyper.Red,colorhyper.Green,colorhyper.Blue));
			
			Log.print("AppHome : : initcheck()", "NIGHT WALLPAPER: :"+Bean.getThemeBg("NIGHT").trim()+" "+ Bean.getWallIndex(Bean.getThemeBg("NIGHT"),"NIGHT"));
			_tv_bgcolorbox.setBackgroundResource(Const.NIGHT_BG[Bean.getWallIndex(Bean.getThemeBg("NIGHT"),"NIGHT")]);
			
			
		}else{
			
			Log.print("AppHome : : initcheck()", "DAY MODE");
			colortext=new ZLColorOption("Colors","defaultLight:Text",new ZLColor(0, 0, 0)).getValue();
			Log.print("AppHome : : initcheck()", "DAY MODE: : defaultText "+ colortext.getIntValue());
			
			Pref.setValue("DAY_TEXT_COLOR_VALUE", String.valueOf(colortext.getIntValue()));
			
			_tv_textcolorbox.setBackgroundColor(Color.rgb(colortext.Red,colortext.Green,colortext.Blue));
			
			colorhyper=new ZLColorOption("Colors","defaultLight:Hyperlink",new ZLColor(60,139,255)).getValue();
			Log.print("AppHome : : initcheck()", "DAY MODE: : defaulthyper "+ colorhyper.getIntValue());
			
			Pref.setValue("DAY_LINK_COLOR_VALUE", String.valueOf(colorhyper.getIntValue()));
			
			_tv_linkcolorbox.setBackgroundColor(Color.rgb(colorhyper.Red,colorhyper.Green,colorhyper.Blue));
			
			Log.print("AppHome : : initcheck()", "DAY WALLPAPER: :"+Bean.getThemeBg("DAY").trim()+" "+Bean.getWallIndex(Bean.getThemeBg("DAY"),"DAY"));
			_tv_bgcolorbox.setBackgroundResource(Const.DAY_BG[Bean.getWallIndex(Bean.getThemeBg("DAY"),"DAY")]);
			
		}
		
		if(infontsize.getValue()>=5){
			
				Log.print("AppHome :: initcheck::",""+infontsize.getValue());
				sbfontsize.setProgress(infontsize.getValue());
				_tv_fsize.setText(String.valueOf(infontsize.getValue()));
		}else{
				Log.print("AppHome :: initcheck::","SET DEFAULT ");
				sbfontsize.setProgress(5);
				_tv_fsize.setText(String.valueOf(intfontsize));
		}
		
	}*/
	
	public void initCheck(){
    	
    	
    	if(new ZLBooleanOption("Options","AutoHyphenation",true).getValue()){
    		 Log.print("LayHome ::initCheck()","CHECKED IS :"+new ZLBooleanOption("Options","AutoHyphenation",true).getValue());
    		_cbox_hypen.setChecked(true);
    	}else{
    		Log.print("LayHome ::initCheck()","CHECKED IS :"+new ZLBooleanOption("Options","AutoHyphenation",true).getValue());
    		_cbox_hypen.setChecked(false);
    	}
    	
    	
    	if(intLineSpece.getValue()!=12){
    		
			Log.print("LayHome : :initCheck : :","LineSpaceDefault :"+intLineSpece.myDefaultValue);
			 Log.print("LayHome : :initCheck : :",""+intLineSpece.getValue());
			_seekbar_LineSpacing.setProgress(intLineSpece.getValue());
			
    	}else{
    		
    		Log.print("LayHome : :initCheck : :","LineSpaceDefault :"+intLineSpece.myDefaultValue);
    		_seekbar_LineSpacing.setProgress(intLineSpece.getValue());	
    	}
    	
    	
    	if(intTopMargin.getValue()!=0 && intBottomMargin.getValue()!=4){
    		Log.print("LayHome : :initCheck ::","DefaultMarginValue :"+intTopMargin.myDefaultValue+" "+intTopMargin.getValue());
    		_tv_marginsValue.setText(String.valueOf(intTopMargin.getValue()));
    		_seekbar_margins.setProgress(intTopMargin.getValue());
    		
    	}else{
    		
    		Log.print("LayHome : :initCheck : :","DefaultMarginValue :"+intTopMargin.myDefaultValue);
    		_tv_marginsValue.setText(String.valueOf(intTopMargin.getValue()));
//    		_seekbar_margins.setProgress(intTopMargin.myDefaultValue);
    	}
    	if(SpaceBeforeOption.getValue()!=0){
    		
    		Log.print("LayHome : :initCheck : :","DefaultPgSpacing Before :"+SpaceBeforeOption.myDefaultValue);
    		_tv_PgSpacingValue.setText(String.valueOf(SpaceBeforeOption.getValue()));
    		_seekbar_PgSpacing.setProgress(SpaceBeforeOption.getValue());
    		
    	}else{
    		Log.print("LayHome : :initCheck : :","DefaultPgSpacing Before :"+SpaceBeforeOption.myDefaultValue);
    		_tv_PgSpacingValue.setText(String.valueOf(SpaceBeforeOption.getValue()));
    		_seekbar_PgSpacing.setProgress(SpaceBeforeOption.getValue());
    		
    		
    	}
    	
    	/*if(LeftIndentOption.getValue()!=0){
    		
    		Log.print("INDENT",String.valueOf(LeftIndentOption.getValue()));
    		_tv_PgIndentValue.setText(String.valueOf(LeftIndentOption.getValue()));
    		
    	}else{
    		_tv_PgIndentValue.setText(String.valueOf(LeftIndentOption.getValue()));
    	}
    	*/
    	
    	if(infontsize.getValue()>=5){
			
			Log.print("AppHome :: initcheck::",""+infontsize.getValue());
			sbfontsize.setProgress(infontsize.getValue());
			_tv_fsize.setText(String.valueOf(infontsize.getValue()));
    	}else{
			Log.print("AppHome :: initcheck::","SET DEFAULT ");
			sbfontsize.setProgress(5);
			_tv_fsize.setText(String.valueOf(intfontsize));
    	}
    	
    }
	
	
	
	
}

